<?php

/**
 * @author dungdhs@gmail.com
 * @copyright 2012
 */

function page_task(){
  return array(
    'detail' => array(
      'func'  => '_page_view',
      'perm'  => 'page view'  
    )
  );
}

function _page_view(){
  global $smarty, $database;
  
  $id = arg(2);
  $res = $database->db_query("SELECT * FROM pages WHERE page_id=%d", $id);
  
  if ($row = $database->db_fetch_assoc($res)){
    theme_title($row['page_title']);
    __ogp_set('og:description', substr(strip_tags($row['page_content']), 0, 120).'...');
    __ogp_set('og:type', 'article');
    
    $smarty->assign('page', $row);
    PGTheme::$pageTemplate = 'newsmain';
    return $smarty->fetch('page_detail.tpl');
  }else system_notfound();
}
?>